package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepDatasetImportLog;
import com.ruoyi.deeplearn.service.IDeepDatasetImportLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 导入日志Controller
 *
 * @author 任伟伟
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/deeplearn/importLog")
public class DeepDatasetImportLogController extends BaseController
{
    @Autowired
    private IDeepDatasetImportLogService deepDatasetImportLogService;

    /**
     * 查询导入日志列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepDatasetImportLog deepDatasetImportLog)
    {
        startPage();
        List<DeepDatasetImportLog> list = deepDatasetImportLogService.selectDeepDatasetImportLogList(deepDatasetImportLog);
        return getDataTable(list);
    }

    /**
     * 导出导入日志列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:export')")
    @Log(title = "导入日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepDatasetImportLog deepDatasetImportLog)
    {
        List<DeepDatasetImportLog> list = deepDatasetImportLogService.selectDeepDatasetImportLogList(deepDatasetImportLog);
        ExcelUtil<DeepDatasetImportLog> util = new ExcelUtil<DeepDatasetImportLog>(DeepDatasetImportLog.class);
        util.exportExcel(response, list, "导入日志数据");
    }

    /**
     * 获取导入日志详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepDatasetImportLogService.selectDeepDatasetImportLogById(id));
    }

    /**
     * 新增导入日志
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:add')")
    @Log(title = "导入日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepDatasetImportLog deepDatasetImportLog)
    {
        return toAjax(deepDatasetImportLogService.insertDeepDatasetImportLog(deepDatasetImportLog));
    }

    /**
     * 修改导入日志
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:edit')")
    @Log(title = "导入日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepDatasetImportLog deepDatasetImportLog)
    {
        return toAjax(deepDatasetImportLogService.updateDeepDatasetImportLog(deepDatasetImportLog));
    }

    /**
     * 删除导入日志
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:importLog:remove')")
    @Log(title = "导入日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepDatasetImportLogService.deleteDeepDatasetImportLogByIds(ids));
    }
}
